import React from 'react'
import {connect} from 'react-redux'

function Reactredux01(props) {
    return (
        <div>
            <h1>我是redux--{props.num}</h1>
            <button onClick={props.add}>点击添加啊</button>
            <button onClick={props.sup}>点击添加啊</button>
        </div>
    )
}

/* const reactredux01 = () => {
    
} */
/* 需要传输2个参数,第一个是映射关系,store 里边的对象,映射到pros的属性里边
第二个参数是dispatch的映射关系,一般不会传,也不会定义
state 就是 reducer里边的state */
const state2props = (state) => {
    return {...state}
}
// 我想將dispatch也归props 来调用,或者是props里边的方法来触发
const patch2props = (dispatch) => {
    return{
        add(){
            const action ={ type:"add"}
            dispatch(action)
        },
        sup(){
            const action ={ type:"sup"}
            dispatch(action)
        }
    }
}


export default connect(state2props,patch2props)(Reactredux01)  